﻿<Window x:Class="DesktopAnnotator.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:properties="clr-namespace:DesktopAnnotator.Properties"
        xmlns:local="clr-namespace:DesktopAnnotator"
        Title="DesktopAnnotator"
        Width="525"
        Height="350"
        AllowsTransparency="True"
        Background="#00FFFFFF"
        Topmost="True"
        WindowState="Maximized"
        WindowStyle="None">
    <Window.Resources>
        <local:CurrentModeToBooleanConverter x:Key="CurrentModeToBooleanConverter" />
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="Close" Executed="Close_Executed" />
        <CommandBinding Command="Properties" Executed="Properties_Executed" />
        <CommandBinding Command="Help" Executed="Help_Executed" />
    </Window.CommandBindings>
    <Window.InputBindings>
        <KeyBinding Key="Escape" Command="Close" />
        <KeyBinding Key="Back" Command="{Binding ClearCommand}" />
    </Window.InputBindings>
    <Grid>
        <InkCanvas x:Name="inkCanvas"
                   Cursor="Pen"
                   DefaultDrawingAttributes="{Binding DrawingAttribute}"
                   EditingMode="{Binding EditingMode}"
                   Strokes="{Binding Strokes}"
                   UseCustomCursor="True">
            <InkCanvas.Background>
                <SolidColorBrush Color="{Binding BackgroundColor, Source={x:Static properties:Settings.Default}}" />
            </InkCanvas.Background>
            <InkCanvas.InputBindings>
                <KeyBinding Key="Escape" Command="Close" />
            </InkCanvas.InputBindings>
            <ContextMenuService.ContextMenu>
                <ContextMenu>
                    <!--  描画操作系メニュー  -->
                    <MenuItem Command="{Binding SelectDrawingModeCommand}"
                              CommandParameter="{x:Static local:DrawingMode.Pen}"
                              Header="ペン"
                              IsCheckable="True"
                              IsChecked="{Binding CurrentMode,
                                                  Mode=OneWay,
                                                  Converter={StaticResource CurrentModeToBooleanConverter},
                                                  ConverterParameter={x:Static local:DrawingMode.Pen}}" />
                    <MenuItem Command="{Binding SelectDrawingModeCommand}"
                              CommandParameter="{x:Static local:DrawingMode.Marker}"
                              Header="マーカー"
                              IsCheckable="True"
                              IsChecked="{Binding CurrentMode,
                                                  Mode=OneWay,
                                                  Converter={StaticResource CurrentModeToBooleanConverter},
                                                  ConverterParameter={x:Static local:DrawingMode.Marker}}" />
                    <MenuItem Command="{Binding SelectDrawingModeCommand}"
                              CommandParameter="{x:Static local:DrawingMode.Eraser}"
                              Header="消しゴム"
                              IsCheckable="True"
                              IsChecked="{Binding CurrentMode,
                                                  Mode=OneWay,
                                                  Converter={StaticResource CurrentModeToBooleanConverter},
                                                  ConverterParameter={x:Static local:DrawingMode.Eraser}}" />
                    <MenuItem Command="{Binding SelectDrawingModeCommand}"
                              CommandParameter="{x:Static local:DrawingMode.EraseByStroke}"
                              Header="ストロークを消去"
                              IsCheckable="True"
                              IsChecked="{Binding CurrentMode,
                                                  Mode=OneWay,
                                                  Converter={StaticResource CurrentModeToBooleanConverter},
                                                  ConverterParameter={x:Static local:DrawingMode.EraseByStroke}}" />
                    <Separator />
                    <MenuItem Command="{Binding ClearCommand}" Header="クリア" />
                    <Separator />
                    <!--  その他メニュー  -->
                    <MenuItem Command="Properties" Header="設定" />
                    <MenuItem Command="Help" Header="About" />
                    <Separator />
                    <MenuItem Command="Close" Header="終了" />
                </ContextMenu>
            </ContextMenuService.ContextMenu>
        </InkCanvas>
    </Grid>
</Window>
